﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Emporium_Web.DBML;

namespace Emporium_Web
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            TablasDataContext database = new TablasDataContext();            

            var usuario = database.TG_Usuario.FirstOrDefault(c => c.Usuario_Codigo.ToUpper() == txtUserName.Text.ToUpper());
            if (usuario == null)
            {
                warningMessage.Visible = true;
                lblWarningMessage.Text = "Usuario no existe.";
            }
            else
            {
                Session["UserName"] = txtUserName.Text;
                Response.Redirect("ClienteList.aspx");
            }
        }
    }
}